#ifndef NET_RPC_RPC_H
#define NET_RPC_RPC_H

#include <string>

#include "base/callback.h"
#include "google/protobuf/service.h"

using std::string;

class RPC : public google::protobuf::RpcController {
 public:
  enum RpcStatus {
    PENDING = 0,
    SUCCEED = 1,
    DEADLINE_EXCEEDED = 2,
    CANCELLED = 3
  };

  RPC();
  virtual void Reset();
  virtual string ErrorText() const;
  virtual bool Failed() const;
  virtual void StartCancel();
  virtual void SetFailed(const string&);
  virtual bool IsCanceled() const;
  virtual void NotifyOnCancel(Closure*);
  void set_deadline(float deadline);
  RPC::RpcStatus status();
  void SetStatus(RpcStatus status);
  float deadline() { return deadline_; }

 private:
  RpcStatus status_;
  float deadline_;
};

#endif
